]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dbusServices/extensions: Only show dialog when loaded
authorFlorian Müllner <fmuellner@gnome.org>
Tue, 21 Nov 2023 12:28:30 +0000 (13:28 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 30 Nov 2023 17:44:58 +0000 (18:44 +0100)
After the port to ESM, an extension's `prefs.js` file is imported
asynchronously. An unintended side effect of that is that we now
show the dialog before anything can be added to the window (either
by the extension, or the fallback error UI).

The delay almost always won't be noticeable to users, but it's
bad practice and prevents extensions from using some API that
only works before the window is realized.

To address the issue, add a `loaded` signal to the dialog that allows
the caller to postpone showing the window until the UI is ready.

Close: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7201
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3025>
(cherry picked from commit 7f7ae31fa38d03fb64e0c29717a88c6edf420096)

js/dbusServices/extensions/extensionPrefsDialog.js
js/dbusServices/extensions/extensionsService.js

index 6c1b5d50891328e37e165442cc3d2b9e12d84641..50b2e92f597fe826649692dc0cee815f786f9206 100644 (file)
@@ -9,6 +9,9 @@ import Gtk from 'gi://Gtk?version=4.0';
 
 export const ExtensionPrefsDialog = GObject.registerClass({
     GTypeName: 'ExtensionPrefsDialog',
+    Signals: {
+        'loaded': {},
+    },
 }, class ExtensionPrefsDialog extends Adw.PreferencesWindow {
     _init(extension) {
         super._init({
@@ -21,7 +24,7 @@ export const ExtensionPrefsDialog = GObject.registerClass({
         this._loadPrefs().catch(e => {
             this._showErrorPage(e);
             logError(e, 'Failed to open preferences');
-        });
+        }).finally(() => this.emit('loaded'));
     }
 
     async _loadPrefs() {
index 0d60fb60eb48274c29432a44c77f61def375eee7..f3f8f4156d2df820994ede0b0f5e889009a62591 100644 (file)
@@ -137,6 +137,8 @@ export const ExtensionsService = class extends ServiceImplementation {
             const extension = extensionManager.createExtensionObject(serialized);
 
             this._prefsDialog = new ExtensionPrefsDialog(extension);
+            this._prefsDialog.connect('loaded',
+                () => this._prefsDialog.show());
             this._prefsDialog.connect('realize', () => {
                 let externalWindow = null;
 
@@ -157,8 +159,6 @@ export const ExtensionsService = class extends ServiceImplementation {
             });
             this.hold();
 
-            this._prefsDialog.show();
-
             invocation.return_value(null);
         } catch (error) {
             this._handleError(invocation, error);